﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace wms_wpf.Converter
{
    public class StringToColorConverter : IValueConverter
    {

        //public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        //{
        //    string source = values[0] as string;
        //    string toCheck = values[1] as string;

        //    return !string.IsNullOrEmpty(source) && source.Contains(toCheck);
        //}

        //public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        //{
        //    throw new NotImplementedException();
        //}
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string result = (string)value;
            if (result != null)
            {
                if (result.Contains("缺料"))
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ff0033"));
                }
                else
                {
                    return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#101110"));
                }
            }
            return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#101110"));
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
